package tw.com.tuan.ui.util;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.ScrollPane;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;

public class CanvasArea {
	private static JPanel jpCanvas;
	private static ScrollPane scrollpane;
	
	public static JPanel getPanel() {
		
		jpCanvas = new JPanel();
		jpCanvas.setBackground(Color.LIGHT_GRAY);
		
		//jpCanvas.setLayout(new BorderLayout());
		
		//jpCanvas.setLayout(new BorderLayout(600,400));
		
		//jpCanvas.setPreferredSize(new Dimension(600, 400));
		//jpCanvas.setBorder(new EmptyBorder(5,5,5,5));
		
		scrollpane = new ScrollPane();
		scrollpane.setPreferredSize(new Dimension(600, 400));
		
		scrollpane.addFocusListener(new FocusListener (){
			@Override
			public void focusGained(FocusEvent arg0) {    
			}

			@Override
			public void focusLost(FocusEvent arg0) {				
			}
			
		});

		scrollpane.addMouseListener(new MouseListener(){

			@Override
			public void mouseClicked(MouseEvent arg0) {	
				System.out.println("Position: "+ scrollpane.getScrollPosition().toString());
			}

			@Override
			public void mouseEntered(MouseEvent arg0) {				
			}

			@Override
			public void mouseExited(MouseEvent arg0) {				
			}

			@Override
			public void mousePressed(MouseEvent arg0) {				
			}

			@Override
			public void mouseReleased(MouseEvent arg0) {				
			}});
		
		jpCanvas.add(scrollpane,BorderLayout.CENTER);
		
		setScrollView();
		
		return jpCanvas;
	}

	
	public static void setScrollView() {
		Canvas canvas = new Canvas();
				
		canvas.setPreferredSize(new Dimension(1024, 800 ));
		canvas.setBackground(Color.BLACK);
		scrollpane.add(canvas);
	}
	
	
}
